package com.wzh.rabbitmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @description:
 * @author: WZH
 * @time: 2021/6/16 15:20
 */
@Component
public class FanoutProducer {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(){
        System.out.println("FanoutProducer");
        //第一个参数是交换机的名称 ，第二个参数是routerKey 这里设置为空字符串即可，第三个参数是要发送的消息
        rabbitTemplate.convertAndSend("fanoutExchange","","发布/订阅");
    }
}